package redis

import (
	"fmt"
	"github.com/go-redis/redis/v8"
	"shenzhou/B/srv/appconfig"
)

var RedisClient *redis.Client

func ExampleNewClient() {
	data := appconfig.ViperConfig.Redis
	RedisClient = redis.NewClient(&redis.Options{
		Addr:     data.Addr,
		Password: data.Password, // no password set
		DB:       data.Db,       // use default DB
	})

	pong, err := RedisClient.Ping(RedisClient.Context()).Result()
	fmt.Println(pong, err)
	// Output: PONG <nil>
	if err != nil {
		panic(err)
	} else {
		fmt.Println("redis连接成功")
	}
}
